const path = require('path')
const scssVariables = require('./src/assets/variables.scss.js');
const timestamp = new Date().getTime();
function resolve(dir) {
	return path.join(__dirname, dir)
}
module.exports = {
	lintOnSave: false,
	devServer: {
		host: '0.0.0.0',
		port: process.env.VUE_APP_PORT,
		https: false,
		open: true,
		proxy: {
			[process.env.VUE_APP_BASE_API]: {
				// target: `http://39.96.175.50:8020/`,
				target: `http://127.0.0.1:8020/`,
				changeOrigin: true,
				pathRewrite: {
					['^' + process.env.VUE_APP_BASE_API]: ''
				}
			},
			// ['/file']: {
			// 	target: `http://192.168.1.253:9000/`,
			// 	changeOrigin: true,
			// 	pathRewrite: {
			// 		['^' + '/file']: ''
			// 	}
			// },
		}
	},
	configureWebpack: {
		resolve: {
			alias: {
				'@': resolve('src')
			}
		},
		output: { // 输出重构  打包编译后的 文件名称  【模块名称.时间戳】
			filename: `[name].${timestamp}.js`,
			chunkFilename: `[name].${timestamp}.js`
		},
		module:{
			rules:[
				{
					test: /\.(glb)$/,
					loader: 'url-loader'
				},
			]
		}
	},
	css: {
        loaderOptions: {
			sass: {
			// 全局sass变量
			//sass-loader 8.0.0以前版本 , v8 - prependData, v10+ - additionalData
            data: Object.keys(scssVariables)
              .map(k => `$${k.replace('_', '-')}: ${scssVariables[k]};`)
              .join('\n'),
          }
        }
	},
	publicPath: process.env.NODE_ENV === 'production' ? '/' : '/'
}
